#define _CRT_SECURE_NO_WARNINGS 1 

#include <iostream>
#include <vector>
using namespace std;
#include "AVLTree.h"
void TestAVLTree1()
{
	AVLTree<int, int> t;
	int a[] = { 4,2,6,1,3,5,15,7,16,14 };

	for (auto e : a)
	{
		if (e == 14)
			int x = 0;

		t.Insert({ e,e });
		//cout << "Insert:" << e << endl;
		//t.IsBalance();
	}
	t.InOrder();
	cout << t.IsBalance() << endl;
}

void TestAVLTree2()
{
	const int N = 1000000;
	vector<int> v;
	v.reserve(N);
	srand(time(0));
	for (size_t i = 0; i < N; i++)
	{
		v.push_back(rand() + i);
	}

	size_t begin = clock();
	AVLTree<int, int> t;
	for (auto e : v)
	{
		t.Insert({ e,e });
	}
	size_t end = clock();

	cout << "Insert:" << end - begin << endl;
	cout << t.IsBalance() << endl;
	cout << "Height:" << t.Height() << endl;
	cout << "Size:" << t.size() << endl;
	//t.InOrder();

	size_t begin2 = clock();
	for (size_t i = 0; i < N; i++)
	{
		t.Find(rand() + i);
	}

	size_t end2 = clock();
	cout << "Find:" << end2 - begin2 << endl;
}

int main()
{
	TestAVLTree2();

	return 0;
}